var dieSound : AudioClip;
var splitSkeet : Transform;
var skeetVelocityMax: float;
var skeetVelocityMin : float;
private var sc : SoundController = null;
var liveTime : int;
private var dead : boolean = false;

function Start(){
  var gameobject = GameObject.Find("Player");
   // (ScriptName is the name of the javascript file)
  sc = gameobject.GetComponent("SoundController");
}

function Die () {
	if (!dead){
	  Debug.Log("Hi, Die Script Called.");
      Destroy(gameObject);
	  skeetsScore.Score++;
	  Debug.Log("Score!");
	//scorekeeping stuff
	// score += 1 * multiplier;
	  audio.PlayOneShot(dieSound);
      //sc.HitSound();
	  Debug.Log("Played dieSound: " + dieSound);	
	  split();
	  dead = true;
	}
}

function split(){
	Debug.Log("Sup");
	var position = transform.position;
	clone1 = Instantiate(splitSkeet, position, transform.rotation);
	clone2 = Instantiate(splitSkeet, position, transform.rotation);
	clone1.rigidbody.AddForce (random() , random() , random()  , ForceMode.Impulse);
	clone2.rigidbody.AddForce (random() , random() , random()  , ForceMode.Impulse);
	Destroy(clone1.gameObject,liveTime);
	Destroy(clone2.gameObject,liveTime);
}

function random(){
	rand = Random.Range(skeetVelocityMin, skeetVelocityMax);
	print (rand);
	return rand;
}
